package com.milo.coding.proxy.dyna.jdk;

import com.milo.coding.proxy.dyna.IUserService;
import com.milo.coding.proxy.dyna.UserServiceImpl;

import java.lang.reflect.Proxy;

/**
 * @Auther milo
 * @Description
 * @Date 2021-02-28 13:41
 */
public class Main {
    public static void main(String[] args) {
        UserServiceImpl userService = new UserServiceImpl();
        MyInvocationHandler myInvocationHandler = new MyInvocationHandler(userService);
        IUserService userServiceProxy = (IUserService)Proxy.newProxyInstance(userService.getClass().getClassLoader(), userService.getClass().getInterfaces(), myInvocationHandler);
        System.out.println(userServiceProxy.getName());
        System.out.println(userServiceProxy.getAge());
    }
}
